<html>
<head>
    <script src="http://cdn.bootcss.com/jquery/1.7.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/socket.io/1.4.5/socket.io.min.js"></script>
    <script>
        $(function(){
            var iosocket = io('http://127.0.0.1:3000');

            iosocket.on('connect', function () {
                $('#incomingChatMessages').append($('<li>Connected</li>'));

                iosocket.on('message', function(message) {
                    $('#incomingChatMessages').append($('<li></li>').text(message));
                });
                iosocket.on('disconnect', function() {
                    $('#incomingChatMessages').append('<li>Disconnected</li>');
                });
            });

            $('#sub').click(function(event) {
                    event.preventDefault();
                    iosocket.send($('#outgoingChatMessage').val());
//                    $('#incomingChatMessages').append($('<li></li>').text($('#outgoingChatMessage').val()));
                    $('#outgoingChatMessage').val('');
            });
        });
    </script>
</head>
<body>
Incoming Chat:&nbsp;<ul id="incomingChatMessages"></ul>
<br />
<input type="text" id="outgoingChatMessage"><br>
<button type="button" id="sub">submit</button>
</body>
</html>